# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=sddm
pkgver=9999_git20240428
_pkgver=0.21.0
pkgrel=0
pkgdesc="Simple Desktop Display Manager"
url="https://github.com/sddm/sddm/"
# armhf blocked by qt5-qtdeclarative
arch="all !armhf"
license="GPL-2.0-only"
depends="
	dbus-x11
	linux-pam
	upower
	xorg-server
	"
makedepends="
	extra-cmake-modules
	libxcb-dev
	linux-pam-dev
	py3-docutils
	qt6-qtbase-dev
	qt6-qtdeclarative-dev
	qt6-qttools-dev
	samurai
	systemd-dev
	upower-dev
	utmps-dev
	"
subpackages="$pkgname-doc $pkgname-lang $pkgname-openrc"
install="sddm.pre-install"
langdir="/usr/share/sddm/translations"
pkgusers="sddm"
pkggroups="sddm"
source="https://github.com/sddm/sddm/archive/v$_pkgver/sddm-v$_pkgver.tar.gz
	0001-pam-path-fix.patch
	0003-disable-automatic-portal-launching.patch
	sddm.initd
	sddm.confd
	"
builddir="$srcdir/$pkgname-$_pkgver"

# secfixes:
#   0.19.0-r0:
#     - CVE-2020-28049

build() {
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_MAN_PAGES=ON \
		-DBUILD_WITH_QT6=ON \
		-DENABLE_JOURNALD=ON \
		-DNO_SYSTEMD=OFF \
		-DUSE_ELOGIND=OFF \
		-DUID_MIN=500 \
		-DUID_MAX=65000 \
		-DDBUS_CONFIG_DIR=/usr/share/dbus-1/system.d
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	install -Dm755 "$srcdir"/sddm.initd "$pkgdir"/etc/init.d/sddm
	install -Dm644 "$srcdir"/sddm.confd "$pkgdir"/etc/conf.d/sddm
}

lang() {
	pkgdesc="Languages for package $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel lang"
	depends="$depends_lang"

	amove usr/share/sddm/translations-qt6
}

sha512sums="
2e8e460e7f318f20a406dcbb1a9fa1dc78b6a5b8d888bfbbaae22b9c642dbc49cf2ac682b4ea9ed847bbafa9bdc361ba08795e59cad970088b370caaaa70f458  sddm-v0.21.0.tar.gz
42a0b24717820d98a42d178b5d3a40441672d496c9d8f7c2f8002d770a2718324e9d00d0f27602232b91e8bb042693125507d6cb8371b6f6f211f2b95babe666  0001-pam-path-fix.patch
bc7b572331de32245abba234e3537885a3d9dd20273a12bd7a82eb754467dd3c753fc4d90ec24cc206f7df0210cf3119dd056c477168b4173b77fc335b6546b0  0003-disable-automatic-portal-launching.patch
4876bf46790dd507f0df803987ad81d7ff2a00c22a8aabec88dd0e3a23aeda92aac59f08ef56ed1bf2b5cb9443077e77b31c9f453bafab2fd6f533be242fcbd4  sddm.initd
b841282b96110ec59a7aa539db0737327b09549d55c78dc4b2c3b28b4a6ad1facf015b3175cb6d3a38f13e47aa6314ef3dc1514a4e60dd653a97409ec54ba706  sddm.confd
"
